package com.cheer.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author cheer
 */
@Getter
@AllArgsConstructor
public enum TitleEnum {

    NO(0, "未获得文明号"),
    CITY(1, "市级文明号"),
    PROVINCE(2, "省级文明号"),
    NATION(3, "国家级文明号");

    private final Integer type;
    private final String description;

    public static boolean isValidTitle(int type) {
        if (type == 0) {
            return false;
        }
        for (TitleEnum titleEnum : TitleEnum.values()) {
            if (titleEnum.type == type) {
                return true;
            }
        }
        return false;
    }

    public static TitleEnum getByType(int type) {
        for (TitleEnum titleEnum : TitleEnum.values()) {
            if (titleEnum.getType() == type) {
                return titleEnum;
            }
        }
        return null;
    }

}
